import 'package:hi_net_v1/net/request/base_req.dart';
import 'package:hi_net_v1/net/response/base_response.dart';

class HiNet {
  HiNet._internal();

  static HiNet? _instance;

  static HiNet getInstance() {
    if (_instance == null) {
      _instance = HiNet._internal();
    }
    return _instance!;
  }

  fire(BaseRequest request) async {
    print("url: ${request.url()}");
    BaseResponse<String> response = await send(request);
    print("response: $response");
  }

  Future<BaseResponse<String>> send(BaseRequest request) async {
    await Future.delayed(Duration(seconds: 1));

    Map<String, dynamic> data = {
      "desc": "一起来做个App吧",
      "id": 10,
      "imagePath":
          "https://www.wanandroid.com/blogimgs/50c115c2-cf6c-4802-aa7b-a4334de444cd.png",
      "isVisible": 1,
      "order": 1,
      "title": "一起来做个App吧",
      "type": 0,
      "url": "https://www.wanandroid.com/blog/show/2"
    };
    BaseResponse<String> result = BaseResponse<String>(data.toString());
    result.statusCode = 200;
    result.errorMsg = "";
    result.errorCode = 0;
    return result;
  }
}
